package com.cloud.nacos.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author:ZhouYang
 * @Description:
 * @Date: Created in 2020/8/28 10:40
 * @Modified By：  直接通过RestTemplate调用服务
 */
@Slf4j
@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/consumer")
    public String consumer() {
        log.info("---------消费者开始------------");
        //调用服务
        String result = restTemplate.getForObject("http://nacos-provider/provider", String.class);
        log.info("---------消费者结束--------result{}----", result);
        return result;
    }
}
